#include <stdio.h>

#define LENGTH = 10;

void q8_2() {
	int a, b, *pa, *pb;
	scanf("%d %d", &a, &b);
	pa = &a;
	pb = &b;
	if (a < b) {
		pa = &b;
		pb = &a;
	}
	printf("A:%d, B:%d\n", a, b);
	printf("PA:%d, PB:%d\n", *pa, *pb);
}

void q8_3() {
	void q8_3_method(int *pa, int *pb);
	int a, b;
	int *pa, *pb;
	scanf("%d %d", &a, &b);
	pa = &a;
	pb = &b;
	if (a < b) {
		q8_3_method(pa, pb);
	}
	printf("A:%d, B:%d\n", a, b);
	printf("PA:%d, PB:%d", *pa, *pb);
}

void q8_3_method(int *pa, int *pb) {
	int temp = *pa;
	*pa = *pb;
	*pb = temp;
}

void q8_5() {
	void q8_5_method(int *a, int *b, int *c);
	int a, b, c;
	int *pa, *pb, *pc;
	scanf("%d %d %d", &a, &b, &c);
	pa = &a;
	pb = &b;
	pc = &c;
	q8_5_method(pa, pb, pc);
	printf("A:%d, B:%d, C:%d\n", a, b, c);
	printf("A:%d, B:%d, C:%d", *pa, *pb, *pc);
}

void q8_5_method(int *a, int *b, int *c) {
	void q8_5_method1(int *pa, int *pb);
	if (&a < &b) {
		q8_5_method1(a, b);
	}
	if (&a < &c) {
		q8_5_method1(a, c);
	}
	if (&b < &c) {
		q8_5_method1(b, c);
	}
}

void q8_5_method1(int *pa, int *pb) {
	int temp = *pa;
	*pa = *pb;
	*pb = temp;
}

void q8_6() {
	int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
	int *pa = &a[0];
	for (int i = 0; i < 10; ++i) {
		if (i == 9) {
			printf("a[%d]=%d", i, a[i]);
		} else {
			printf("a[%d]=%d, ", i, a[i]);
		}
	}
	printf("\n");
	for (int i = 0; i < 10; i++, pa++) {
		if (i == 9) {
			printf("a[%d]=%d", i, *pa);
		} else {
			printf("a[%d]=%d, ", i, *pa);
		}
	}
	printf("\n");
	for (int i = 0; i < 10; i++) {
		if (i == 9) {
			printf("a[%d]=%d", i, *(a + i));
		} else {
			printf("a[%d]=%d, ", i, *(a + i));
		}
	}
	printf("\n");
	for (int i = 0; i < 10; i++) {
		int size = sizeof(a[i]);
		if (i == 9) {
			printf("a[%d]=%d", i, *(&a[i - size] + size));
		} else {
			printf("a[%d]=%d, ", i, *(&a[i - size] + size));
		}
	}
}

void q8_8() {
	void q8_8_method(int *p1, int *p2);
	int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
	for (int i = 0; i < 10 / 2; i++) {
		q8_8_method(&a[i], &a[10 - i - 1]);
	}
	for (int i = 0; i < 10; ++i) {
		if (i == 9) {
			printf("a[%d]=%d", i, a[i]);
		} else {
			printf("a[%d]=%d, ", i, a[i]);
		}
	}
}

void q8_8_method(int *p1, int *p2) {
	int temp = *p1;
	*p1 = *p2;
	*p2 = temp;
}

void q8_10() {
	void q8_10_method(int *a);
	int a[10] = {11, 32, 35, 14, 345, 66, 7, 58, 29, 110};
	int *p = &a[0];
	q8_10_method(p);
	for (int i = 0; i < 10; ++i) {
		if (i == 9) {
			printf("a[%d]=%d\n", i, a[i]);
		} else {
			printf("a[%d]=%d, ", i, a[i]);
		}
	}
}

void q8_10_method(int *a) {
	void q8_10_method1(int *p1, int *p2);
	for (int i = 0; i < 9; i++) {
		int minIndex = i;
		for (int j = i + 1; j < 10; j++) {
			if (a[j] > a[minIndex]) {
				minIndex = j;
			}
		}
		q8_10_method1(&a[i], &a[minIndex]);
	}
}

void q8_10_method1(int *p1, int *p2) {
	int temp = *p1;
	*p1 = *p2;
	*p2 = temp;
}

int main() {
//	q8_2();
//	q8_3();
//	q8_5();
//	q8_6();
//	q8_8();
	q8_10();
	return 0;
}